package com.gxm.练习.模式.单例;

public class Single {
    private static Single single = new Single();

    private String s;

    private Single(){};

    public static Single getSingle(){
        return single;
    }

    public void getS(String s,long sleep) throws InterruptedException {
        synchronized (this){
            this.s = s;
            System.out.println(Thread.currentThread().getName() + "|" + this.s + "前");
            Thread.sleep(sleep);
            System.out.println(Thread.currentThread().getName() + "|" + this.s + "后");
        }

    }
}
